package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.mapper.NursingLevelMapper;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description NursingLevelServiceImpl
 * @Author jack
 * @Date 2024-08-27
 */
@Slf4j
@Service
public class NursingLevelServiceImpl implements NursingLevelService {
    @Autowired
    private NursingLevelMapper nursingLevelMapper;


    @Override
    public void delete(Long id) {
        nursingLevelMapper.delete(id);
    }

    @Override
    public void changeStatus(Integer id, Integer status) {
        nursingLevelMapper.changeStatus(id,status);
    }

    @Override
    public List<NursingLevelVo> install() {
        List<NursingLevelVo> list=nursingLevelMapper.install();
        return list;
    }

    @Override
    public void insert(NursingLevelVo nursingLevelVo) {

        nursingLevelMapper.insert(nursingLevelVo);
    }

    @Override
    public PageResponse<NursingLevelVo> listByPage(Integer pageNum, Integer pageSize, String name, Integer status) {
        //调用PageHelper.startPage设置页码和每页显示几个
        PageHelper.startPage(pageNum,pageSize);
        //执行数据库查询
        Page<NursingLevelVo> page=nursingLevelMapper.selectByPage(name,status);

        //封装PageResponse
        PageResponse<NursingLevelVo>pageResponse=new PageResponse<>(page);
        pageResponse.setRecords(page.getResult());

        return pageResponse;

    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Override
    public NursingLevelVo serch(Integer id) {
      NursingLevelVo nursingLevelVo =nursingLevelMapper.serch(id);
        return nursingLevelVo;
    }

    @Override
    public void update(NursingLevelVo nursingLevelVo) {
        nursingLevelMapper.update(nursingLevelMapper);

    }
}
